#ifndef TCPSOCKET_H
#define TCPSOCKET_H

#include <iostream>
#include <map>

#include "handler.h"
#include <queue>

#define BUFF_SIZE 1024

class EventLoop;

class TcpSocket: public Handler
{
public:
    TcpSocket(EventLoop *loop, int fd);
    ~TcpSocket();

protected:
    EventLoop *m_evLoop;
    std::queue<std::string> m_sendQueue;
    virtual void recvData(char *msg);
    void sendData(const char *msg);

private:
    char m_recvBuff[BUFF_SIZE];
    char m_sendBuff[BUFF_SIZE];
    void handleRead();
    void handleWrite();
};

typedef TcpSocket* TcpSocketPtr;
typedef std::map<int, TcpSocketPtr> TCPSocketMap; //fd, TCPSocket*

#endif // TCPSOCKET_H
